package com.example.demo.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.example.demo.handler.ChatMessageTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import dev.langchain4j.data.message.ChatMessageType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.ibatis.type.EnumTypeHandler;

import java.time.LocalDateTime;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("message")
public class Message {
    @TableId(value = "id",type = IdType.AUTO)
    private Long id;

    @Schema(description = "用户id")
    private Long userId;

    @Schema(description = "会话id")
    private Long sessionId;

    @Schema(description = "消息内容")
    private String content;

    @TableField(typeHandler = ChatMessageTypeHandler.class)
    @Schema(description = "消息类型（USER: 用户, AI: AI 回复）")
    private ChatMessageType type;

    @Schema(description = "用来标记这个消息是属于普通对话的,还是知识库对话")
    private Integer tag;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdAt;
}
